#include <QtGui>
#include <QApplication>
#include <QPushButton>
#include <QMessageBox>
#include <QTextEdit>
#include <QSystemTrayIcon>
#include <QtSingleApplication>

#include <iostream>
using namespace std;

#include "window.h"
#include "test.h"

int main(int argc, char *argv[])
{
  //  Q_INIT_RESOURCE(systray);
  
  //QApplication app(argc, argv);
  QtSingleApplication app(argc, argv);
  /*
  if(app.isRunning())
    {
      cout << "another instance is running " << endl;
      return 0;
    }
  */

  if(app.sendMessage("Wake up!"))
    return 0;

  test t;
  t.hide();
  app.setActivationWindow(&t);
  //QtSingleApplication::setActiveWindow(&t);
  QObject::connect(&app, SIGNAL(messageReceived(const QString&)), &t, SLOT(showOnTop(const QString&)));

  /*
  if(app.sendMessage("Wake up!"))
    return 0;
  QTextEdit logview;
  logview.show();
  app.setActivationWindow(&logview);
  QObject::connect(&app, SIGNAL(messageReceived(const QString&)), &logview, SLOT(append(const QString&)));
  */




  /*
    if (!QSystemTrayIcon::isSystemTrayAvailable()) {
    QMessageBox::critical(0, QObject::tr("Systray"),
			  QObject::tr("I couldn't detect any system tray "
				      "on this system."));
    return 1;
  }
  QApplication::setQuitOnLastWindowClosed(false);
  */
  
  return app.exec();
}
